#ifndef prs_FrmSplitter_H
#define prs_FrmSplitter_H

#include "prs_FrmFunc.h"
#include "prs_FrmControl.h"
#include "prs_FrmDefTemplate.h"
#include "prs_FrmRules.h"
#include "prs_FrmGeom.h"
#include "prs_FrmSplitterStyle.h"
#include "frm_control_TSplitter.h"

namespace prs {

///////////////////////////////////////////////////////////////////////////////

struct TNodeFrmVSplitter : public TNodeFrmControl
{
  DECLARE_ClientNode()
  //
  typedef TNodeFrmVSplitterStyle      TStyle;
  typedef frm::control::TSplitterVert TControl;
  //
  TAttrNodeType<nodeType_VSplitter> NodeType;
  TAttrPointerNoCopy<attrName_Control,frm::control::TSplitterVert*> Control;
  //
  TAttrInteger<attrName_Weight> Weight;
  //
  TNodeFrmVSplitter() : NodeType(this),Control(this),Weight(this) { Weight.SetValue(-1); }
 ~TNodeFrmVSplitter() { delete Control.GetValue();}
};
                   
///////////////////////////////////////////////////////////////////////////////

struct TRuleFrmVSplitter : public snt::TRule
{
  TRuleFrmVSplitter(
    snt::text::TContext &Context,
    svl::TVariant &VParentNode,
    TRuleFrmChildrenBase &RChildren,
    TRuleSetNodeIdOptionally &RSetNodeIdOptionally,
    TRuleFrmGeom &RFrmGeom,
    TRuleSetAttrValue &RSetAttrValue,
    TRuleSetStyle &RStyle
  );

private:  
  TNodeFrmVSplitter *GetNode() { return dynamic_cast<TNodeFrmVSplitter*>(vParentNode.Pointer());}
  //
  void FSetGeometry(snt::TParams &Params) { rGeometry.SetGeom( &GetNode()->Geometry.Value );}
  bool FSetParam(TRuleSetAttrValue::TFuncValueIdentParams &Params) {
    return TNodeDefTemplate::AddLinkAttrByParamId(Params.Attr,TFrmIntegerValue(),Params.Ident,Params.OutError);
  }
  //
  svl::TVariant &vParentNode;
  TRuleFrmGeom &rGeometry;
  snt::TRule  RAttr,RAttr1;
  snt::TAlter AAttr1;
  svl_Except;
};

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

struct TNodeFrmHSplitter : public TNodeFrmControl
{
  DECLARE_ClientNode()
  //
  typedef TNodeFrmHSplitterStyle      TStyle;
  typedef frm::control::TSplitterHorz TControl;
  //
  TAttrNodeType<nodeType_HSplitter> NodeType;
  TAttrPointerNoCopy<attrName_Control,frm::control::TSplitterHorz*> Control;
  //
  TAttrInteger<attrName_Weight> Weight;
  //
  TNodeFrmHSplitter() : NodeType(this),Control(this),Weight(this) { Weight.SetValue(-1); }
 ~TNodeFrmHSplitter() { delete Control.GetValue();}
};
                   
///////////////////////////////////////////////////////////////////////////////

struct TRuleFrmHSplitter : public snt::TRule
{
  TRuleFrmHSplitter(
    snt::text::TContext &Context,
    svl::TVariant &VParentNode,
    TRuleFrmChildrenBase &RChildren,
    TRuleSetNodeIdOptionally &RSetNodeIdOptionally,
    TRuleFrmGeom &RFrmGeom,
    TRuleSetAttrValue &RSetAttrValue,
    TRuleSetStyle &RStyle
  );

private:  
  TNodeFrmHSplitter *GetNode() { return dynamic_cast<TNodeFrmHSplitter*>(vParentNode.Pointer());}
  //
  void FSetGeometry(snt::TParams &Params) { rGeometry.SetGeom( &GetNode()->Geometry.Value );}
  bool FSetParam(TRuleSetAttrValue::TFuncValueIdentParams &Params) {
    return TNodeDefTemplate::AddLinkAttrByParamId(Params.Attr,TFrmIntegerValue(),Params.Ident,Params.OutError);
  }
  //
  svl::TVariant &vParentNode;
  TRuleFrmGeom &rGeometry;
  snt::TRule  RAttr,RAttr1;
  snt::TAlter AAttr1;
  svl_Except;
};

///////////////////////////////////////////////////////////////////////////////
}

#endif
